<script>

    $(function () {

        var form = new Vue({
            el:'#form',
            data:{
                service_period:window.service_period,
                weeks:window.weeks,
                hours:window.hours,
            },
            mounted:function(){
                $('[name="service_period[week_start]"]').val(this.service_period.week_start);
                $('[name="service_period[week_end]"]').val(this.service_period.week_end);
                $('[name="service_period[time_start]"]').val(this.service_period.time_start);
                $('[name="service_period[time_end]"]').val(this.service_period.time_end);
            },
            methods:{
            }
        });

        var validator = $("#form").validate({
            rules: {
                'service_period[week_start]':{
                    required:true
                },
                'service_period[week_end]':{
                    required:true
                },
                'service_period[time_start]':{
                    required:true
                },
                'service_period[time_end]':{
                    required:true
                },
            },
            messages: {
                'service_period[week_start]':{
                    required:'请选择周几开始'
                },
                'service_period[week_end]':{
                    required:'请选择周几结束'
                },
                'service_period[time_start]':{
                    required:'请选择开始时间'
                },
                'service_period[time_end]':{
                    required:'请选择结束时间'
                },
            },
            submitHandler: function(form) {
                if (Number($('[name="service_period[week_start]"]').val()) > Number($('[name="service_period[week_end]"]').val())){
                    alert('开始日必须早于结束日');
                    return false;
                }else if (Number($('[name="service_period[time_start]"]').val()) > Number($('[name="service_period[time_end]"]').val())){
                    alert('开始时间必须早于结束时间');
                    return false;
                }
                form.submit();
            },
        });
    });
</script>
<style>
    .txt2 {
        border-image: none;
        border-style: none none none solid;
        border-width: medium medium medium 1px;
        color: #666;
        float: left;
        height: 38px;
        line-height: 38px;
        overflow: hidden;
        text-align: center;
        width: 25.133%;
    }
</style>